﻿/**
 * Foxit Software Inc.
 * Copyright(C) 2005-2014, all rights reserved.
 * The following code is copyrighted and contains proprietary information
 * and trade secrets of Foxit Software Inc.

 * Description: Link annotation
 * Author: shaojie zhuo
 */
define(function (require, exports, module) {
    var PDFAnnot = require('./Annot.js');
    require('../Interface.js');
    var Interface = WebPDF.Interface;
    var PDFAction = require('./Action');
    var AnnotDataJSONFormat = WebPDF.PDFData.AnnotDataJSONFormat;

    /**
     * Link annotation
     * @param jsonData annotation data in JSON format
     * @extends WebPDF.PDFData.PDFAnnot
     * @constructor
     */
    var PDFLinkAnnot = function (jsonData) {
        PDFLinkAnnot.superclass.constructor.call(this, jsonData);
        this.pdfDestination = null;
        this.pdfAction = null;
        $.extend(this,{
            /**
             * Get PDF destination of current link annotation.
             * @returns {null | WebPDF.PDFData.PDFDestination}
             */
            getPDFDestination : function () {
                if (this.pdfDestination == null) {
                    this.pdfDestination = new WebPDF.PDFData.PDFDestination(this.annotJSONData[AnnotDataJSONFormat.destinationInfo]);
                }
                return this.pdfDestination;
            },
            /**
             * Get action of current link annotation.
             * @returns {WebPDF.PDFData.PDFAction}
             */
            getAction:  function () {
                if (this.annotJSONData[AnnotDataJSONFormat.action] == null){
                    return null;
                }
                if (this.pdfAction == null) {
                    this.pdfAction = new PDFAction(this.annotJSONData[AnnotDataJSONFormat.action]);
                }
                return this.pdfAction;
            },
            /**
             * Get subtype of link annotation.
             * @returns {WebPDF.Data.AnnotType}
             */
            getSubType: function(){
                return WebPDF.PDFData.AnnotType.Link;
            }
        });

    };
    Interface.extend(PDFLinkAnnot, PDFAnnot);


    WebPDF.PDFData.PDFLinkAnnot = PDFLinkAnnot;
    return WebPDF.PDFData.PDFLinkAnnot;
});